package com.haizol.job;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Configuration;
import org.springframework.messaging.simp.SimpMessagingTemplate;

@Configuration
public class JobConfig {
	@Autowired
	SimpMessagingTemplate messagingTemplate;

	// @Scheduled(fixedRate = 3000)
	public void testToClient() {
		messagingTemplate.convertAndSend("/server/test-msg-to-client", System.currentTimeMillis());
	}

	// @Scheduled(fixedRate = 10000)
	public void testToUser() {
		System.out.println("来自服务端消息");
		// 默认有一个user前缀配置
		messagingTemplate.convertAndSendToUser("1", "/test-msg-to-user", "来自服务器给用户发消息");
	}

}
